# coding:utf-8

from selenium import webdriver

wd = webdriver.Chrome(r'D:\ProGramTools\webdriver\87\chromedriver.exe')

"""
链家地址规则：
https://  cq. lianjia. com  /ershoufang   /dadukou  /bp40ep100
"""

wd.get('https://cq.lianjia.com/ershoufang/dadukou/ty1l2a3bp40ep100/')
lastpageurl = wd.find_element_by_xpath('//*[@id="content"]/div[1]/ul/li[1]/div[1]/div[1]/a')
print(lastpageurl.get_attribute('href'))
wd.get(lastpageurl.get_attribute('href'))
